package com.sk.coin.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sk.coin.sys.entity.Notice;
import com.sk.coin.sys.mapper.NoticeMapper;
import com.sk.coin.sys.service.INoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统资讯公告信息 服务实现类
 * </p>
 *
 * @author Administrator
 * @since 2022-02-21
 */
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {

    @Override
    public Page<Notice> findByPage(Page<Notice> page, String title, String startTime, String endTime, Integer status) {
        return page(page, new LambdaQueryWrapper<Notice>()
                .like(!StringUtils.isNotEmpty(title), Notice::getTitle, title)
                .between(StringUtils.isNotEmpty(startTime), Notice::getCreated, startTime, endTime + " 23:59:59")
                .eq(status != null, Notice::getStatus, status));
    }
}
